# -*- coding: utf-8 -*-
# @Time    : 2022/1/15 16:21
# @Author  : mzp
# @Email   : 2609404548@qq.com
# @File    : page_Community concern.py
# @Software: PyCharm
from time import sleep

from appium import webdriver
from selenium.webdriver.common.by import By

from pages.page_base import PageBase


class Community(PageBase):
    """社区关注功能"""
    community_agreement_locator = (111, 749)  # 同意协议
    community_determine_locator = (342, 817)  # 确定
    community_button_locator=(205,1226)#社区
    community_list_follow_locator=(260,68)#列表页关注
    community_list_follows_locator = (62, 217)  # 关注更多
    community_follow_button_locator=(608,240)#关注按钮
    community_qq_button_locator=(470,1203)#QQ
    community_qq_authorization_locator=(352,1125)#qq授权
    community_follow_locator=(By.XPATH, "//android.support.v7.widget.RecyclerView[@resource-id='com.gfeng.daydaycook:id/recyclerView']"
    "/android.widget.LinearLayout[2]/android.widget.RelativeLayout[1]/android.widget.ImageView[1]")

    def ele_community_agreement(self):
        """同意协议"""
        self.driver.tap([(self.community_agreement_locator)])
        sleep(4)
    def ele_community_determine(self):
        """确定"""
        self.driver.tap([(self.community_determine_locator)])
        sleep(12)
    def ele_community_button(self):
        """社区"""
        self.driver.tap([(self.community_button_locator)])
        sleep(9)
    def ele_community_list_follow(self):
        """列表页关注"""
        self.driver.tap([(self.community_list_follow_locator)])
        sleep(9)
    def ele_community_list_follows(self):
        """关注更多"""
        self.driver.tap([(self.community_list_follows_locator)])
        sleep(9)
    def ele_community_follow_button(self):
        """关注按钮"""
        self.driver.tap([(self.community_follow_button_locator)])
        sleep(9)
    def ele_community_qq_button(self):
        """QQ"""
        self.driver.tap([(self.community_qq_button_locator)])
        sleep(9)
    def ele_community_qq_authorization(self):
        """qq授权"""
        self.driver.tap([(self.community_qq_authorization_locator)])
        sleep(9)
    def ele_community_follow(self):
        self.driver.find_element(*self.community_follow_locator).click()
        sleep(6)
    def  combination(self):
        self.ele_community_agreement()
        self.ele_community_determine()
        self.ele_community_button()
        self.ele_community_list_follow()
        self.ele_community_list_follows()
        self.ele_community_follow_button()
        self.ele_community_qq_button()
        self.ele_community_qq_authorization()
        self.ele_community_follow()